#include <string>
#include <iostream>
#include <string>
#include <conio.h>
#include <math.h>

#include "include\textdisplay.h"

using namespace std;

TextBarMeter::TextBarMeter()
{
    this->current = 0;
    this->total = 0;
    this->width = 0;
    this->label = "";
}

TextBarMeter::TextBarMeter(int startingValue, int startingTotal, int startingWidth, string startingLabel)
{
    this->current = startingValue;
    this->total = startingTotal;
    this->width = startingWidth;
    this->label = startingLabel;
}

TextBarMeter::~TextBarMeter()
{
    //dtor
}

void TextBarMeter::SetValue(int newValue)
{
    this->current = newValue;
}

void TextBarMeter::SetWidth(int newWidth)
{
    this->width = newWidth;
}

void TextBarMeter::SetTotal(int newTotal)
{
    this->total = newTotal;
}

void TextBarMeter::Display()
{
    cout << label << "  ";
    int barLength = round(((float)current / total) * width);
    cout << "[";
    for (int i = 0; i < barLength; i++ )
    {
        cout << "X";
    }

    for (int i = 0; i < width - barLength; i++ )
    {
        cout << "-";
    }

    cout << "] (" << current << "/" << total << ")";
}
